/*
 * @lc app=leetcode.cn id=1475 lang=javascript
 *
 * [1475] 商品折扣后的最终价格
 */

// @lc code=start
/**
 * @param {number[]} prices
 * @return {number[]}
 */
var finalPrices = function (prices) {
  return prices.map((price, index) => {
    for (let i = index + 1; i < prices.length; i++) {
      if (prices[i] <= price) {
        return price - prices[i]
      }
    }
    return price;
  });
};
// @lc code=end

